<template>
  <el-table :data="tableData" border style="width: 100%">
    <el-table-column prop="name" label="图片名称" width="180"></el-table-column>
    <el-table-column label="图片详情" width="180">查看</el-table-column>
    <el-table-column prop="address" label="图片状态">
        <template slot-scope="scope">
          <el-switch 
                     v-model="scope.row.on" 
                     active-value="1"
                     inactive-value="0"
                     active-color="#13ce66"
                     @change="changeSwitch(scope.row)">
          </el-switch>
        </template>
    </el-table-column>
    <el-table-column prop="address" label="操作">
        <template slot-scope="scope">
          <el-button size="mini" class="button_edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" class="button_change" @click="changeEdit(scope.$index, scope.row)">替换</el-button>
          <el-button size="mini" class="button_delete" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  data() {
    return {
      value: '1',
      tableData: [
        {
          name: "四月的好天气",
        },
        {
          name: "留学生入校",
        },
        {
          name: "抗击疫情，我们在行动"
        },
        {
          name: "我们的川农"
        },
        {
          name: "研究中心"
        }
      ]
    };
  },
  methods: {
      changeSwitch(data) {
          console.log(data)
      }
  }
};
</script>
<style>
.button_edit{
    background-color: #67c23a;
    color: white;
}
.button_change{
    background-color: orange;
    color: white;
}
.button_delete{
    background-color:#f56c6c;
    color: white;
}
</style>